package com.example.demo.controller;


import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.response.AlipayToolsFileUploadResponse;
import com.alipay.api.response.AlipayTradePrecreateResponse;
import com.example.demo.pay.PayNeedData;

import com.example.demo.utils.pay.WxPay;
import com.example.demo.utils.pay.ZfbPay;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

@ApiOperation("添加用户")
@ApiImplicitParams(
		{
				@ApiImplicitParam(name = "orderId", value = "商品编号"),
				@ApiImplicitParam(name = "price", value = "总价格"),
		}
)
@RestController
@RequestMapping("/wxPay")
public class WxPayController {

	private WxPay wxPay;
	private ZfbPay zfbPay;
	public WxPayController(WxPay wxPay,ZfbPay zfbPay) {
		this.wxPay = wxPay;
		this.zfbPay = zfbPay;
	}

	@GetMapping
	public String pay(){
		PayNeedData payNeedData = new PayNeedData();
		payNeedData.setPrice(0.01);
		payNeedData.setOrderId(System.currentTimeMillis()+"");
		Map map = wxPay.pay(payNeedData);
		System.out.println(map);

		return (String) map.get("code_url");

	}

}
